package com.example.demo.service.Imp;

import com.example.demo.entity.req.AddDeptRes;
import com.example.demo.entity.req.UpdateDpetRes;
import com.example.demo.entity.table.Dep;
import com.example.demo.mapper.DeptMapper;
import com.example.demo.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DeptServiceImp implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dep> getAllDepts() {
       return deptMapper.getAllDepts();
    }

    @Override
    public int deleteDeptById(Integer id) {
        return deptMapper.deleteDeptById(id);
    }

    @Override
    public int addDept(AddDeptRes apr) {
        //获取当前时间
        apr.setCreateTime(new Date());
        apr.setUpdateTime(new Date());
        return deptMapper.addDept(apr);
    }

    @Override
    public Dep getDeptById(Integer id) {
        return deptMapper.getDeptById(id);
    }


    @Override
    public int updateDept(UpdateDpetRes udp) {
        //获取当前时间
        udp.setUpdateTime(new Date());
        return deptMapper.updateDept(udp);
    }

}
